var page = 0;
var sum = 0;
layui.use(['form', 'layer', 'laydate', 'table', 'laytpl'], function() {
	var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : top.layer,
		$ = layui.jquery,
		laydate = layui.laydate,
		laytpl = layui.laytpl,
		table = layui.table;

	// APP充值列表列表
	var tableIns = table.render({

		elem: '#digitalConfig_table',
		url: request("/console/digitalList"),
		page: true,
		curr: 0,
		limit: Common.limit,
		limits: Common.limits,
		groups: 7,
		cols: [
			[ //表头
				{
					field: 'id',
					title: 'id',
					width: 150,
				},
				{
					field: 'currencyName',
					title: '数字货币名称',
					sort: true,
					width: 150
				}, {
					field: 'convertRate',
					title: '兑法币比例',
					sort: true,
					width: 180
				}, {
					field: 'minWithdrawalScore',
					title: '最小提现金额',
					sort: true,
					width: 180,
					edit: "text"
				}, {
					field: 'withdrawaCharge',
					title: '提现手续费',
					sort: true,
					width: 180,
					edit: "text"
				},
				{
					field: 'minCheckWithdrawalSocre',
					title: '最小审核提现金额',
					sort: true,
					width: 180,
					edit: "text"
				},
				{
					field: 'sort',
					title: '排序',
					sort: true,
					width: 180,
					edit: "text"
				}, {
					fixed: 'right',
					width: 150,
					align: 'center',
					toolbar: '#barDemo'
				}
			]
		]

	});

	// 列表操作
	table.on('tool(digitalConfig_table)', function(obj) {
		var layEvent = obj.event,
			data = obj.data;

		if (layEvent === 'edit') { // 
			Common.invoke({
				url: request('/console/modifyDigitalConfig'),
				data: {
					"id":data.id,
					"minWithdrawalScore": data.minWithdrawalScore,
					"withdrawaCharge": data.withdrawaCharge,
					"minCheckWithdrawalSocre": data.minCheckWithdrawalSocre,
					"sort": data.sort,
				},
				successMsg: "修改配置成功",
				errorMsg:  "修改配置失败，请稍后重试",
				success: function(result) {
					table.reload("digitalConfig_table", {
						page: {
							curr: 1 //重新从第 1 页开始
						}
					})
				},
				error: function(result) {

				}
			});
		}
	});




});
